-
Notifications
You must be signed in to change notification settings - Fork 390
fix(handle-auto-answer): implement-auto-answer-for-desktop-calls #4571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
This pull request is automatically being deployed by Amplify Hosting (learn more). |
…t-decline-button-client-side
|
|
||
| try { | ||
| await task.accept(); | ||
| LoggerProxy.info(`Task auto-answered successfully`, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add metrics for this - it would be good to know if the task was auto answer or not.
We can re-use the accept metrics itself but add another field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed
| } catch (error) { | ||
| // Reset isAutoAnswering flag on failure | ||
| task.updateTaskData({...task.data, isAutoAnswering: false}); | ||
| LoggerProxy.error(`Failed to auto-answer task`, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here.. have metrics for error for auto answer also.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed
| */ | ||
| private async handleAutoAnswer(task: ITask): Promise<void> { | ||
| if (!task || !task.data || !task.data.isAutoAnswering) { | ||
| return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe instead of returning, we throw an error here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kept as return — this guard clause handles the normal operation where most tasks don’t have auto-answer enabled. Throwing an error here would treat the expected path as exceptional and introduce unnecessary error handling in the callers.
| * @param interaction - The interaction object | ||
| * @returns true if this is a digital outbound, false otherwise | ||
| */ | ||
| export const isDigitalOutbound = (interaction: Interaction): boolean => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand we might need this in the future but just curious are we using it now also?
Just an ask.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, we are not using this logic. It’s included for future use.
This implementation has been taken from the Agent Desktop and will be applicable for Desktop, Outdial, and Digital Outbound scenarios.
| * @param agentId - Current agent ID | ||
| * @returns true if agent initiated the outdial, false otherwise | ||
| */ | ||
| export const isAgentInitiatedOutdial = (interaction: Interaction, agentId: string): boolean => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
| export const isAgentInitiatedOutdial = (interaction: Interaction, agentId: string): boolean => { | |
| export const hasAgentInitiatedOutdial = (interaction: Interaction, agentId: string): boolean => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed
adhmenon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
adhmenon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making thw quick changes.
COMPLETES #https://jira-eng-sjc12.cisco.com/jira/browse/CAI-7323
Vidcast Link: https://app.vidcast.io/share/7babff72-18e8-459a-bf67-2727b3256273
This pull request addresses
The need to support automatic task acceptance for contact center agents in specific scenarios, improving agent efficiency and user experience. Currently, agents must manually accept all incoming tasks, which creates unnecessary delays in certain workflows such as:
Additionally, this PR adds support for the AGENT_OFFER_CAMPAIGN_RESERVATION event, which was missing from the SDK's event handling syst
by making the following changes
Auto-Answer Infrastructure
Added helper functions in TaskUtils.ts to determine auto-answer eligibility:
isAutoAnswerEnabled() - Checks if auto-answer is enabled in agent profile
isWebRTCCall() - Validates WebRTC telephony calls
isDigitalOutbound() - Identifies digital outbound interactions (Email/SMS)
isAgentInitiatedOutdial() - Verifies agent-initiated outdial scenarios
shouldAutoAnswerTask() - Main orchestrator that evaluates all auto-answer conditions
TaskManager Integration
Added handleAutoAnswer() private method that automatically accepts tasks when conditions are met
Integrated auto-answer logic into three event handlers:
AGENT_OFFER_CONTACT - Standard contact offers
AGENT_OFFER_CONSULT - Consultation offers
AGENT_OFFER_CAMPAIGN_RESERVATION - Campaign reservation offers (new)
Campaign Reservation Support
Added AGENT_OFFER_CAMPAIGN_RESERVATION to CC_TASK_EVENTS for automatic task lookup
Created new SDK event: TASK_EVENTS.TASK_OFFER_CAMPAIGN_RESERVATION
Implemented event handler in TaskManager.ts following the same pattern as other offer events
Added event listener in sample app (app.js)
Change Type
The following scenarios were tested
< ENUMERATE TESTS PERFORMED, WHETHER MANUAL OR AUTOMATED >
The GAI Coding Policy And Copyright Annotation Best Practices
I certified that
Make sure to have followed the contributing guidelines before submitting.